package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.annotation.RequiresPermissionsDesc;
import com.qf.pojo.DtsRegion;
import com.qf.service.DtsRegionService;
import com.qf.util.ResponseUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Zwnan
 */
@RestController
@RequestMapping("/admin/region")
@CrossOrigin
public class RegionController {

    @Autowired
    private DtsRegionService dtsRegionService;
    @RequiresPermissionsDesc(menu = {"商场管理","关键词"},button ="查询")
    @RequiresPermissions("admin:region:list")
    @GetMapping("/list")
    public Object regionList(@RequestParam(defaultValue = "1")Integer page,
                             @RequestParam(defaultValue = "20") Integer limit){

        IPage<DtsRegion> iPage = dtsRegionService.findPage(page,limit);

        long total = iPage.getTotal();
        List<DtsRegion> records = iPage.getRecords();
        Map map = new HashMap();
        map.put("total", total);
        map.put("items", records);
        return ResponseUtil.ok(map);

    }

}
